<?php namespace App;

use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;

/**
 * App\User
 *
 * @property integer $id 用户标识
 * @property string $username 用户名
 * @property string $email 用户邮箱
 * @property string $phone 用户电话
 * @property string $unionid unionid 针对微信登录用户
 * @property string $openid openid 针对微信登录用户
 * @property string $password 密码
 * @property string $reg_ip 注册ip
 * @property string $reg_time 注册时间
 * @property string $login_ip 最后登录ip
 * @property string $login_time 最后登录时间
 * @property integer $login_count 登录次数
 * @property integer $role 登录角色
 * @property integer $status 用户状态,0锁定,1正常
 * @property string $remember_token
 * @property string $deleted_at
 * @property \Carbon\Carbon $created_at
 * @property \Carbon\Carbon $updated_at
 * @method static \Illuminate\Database\Query\Builder|\App\User whereId($value)
 * @method static \Illuminate\Database\Query\Builder|\App\User whereUsername($value)
 * @method static \Illuminate\Database\Query\Builder|\App\User whereEmail($value)
 * @method static \Illuminate\Database\Query\Builder|\App\User wherePhone($value)
 * @method static \Illuminate\Database\Query\Builder|\App\User whereUnionid($value)
 * @method static \Illuminate\Database\Query\Builder|\App\User whereOpenid($value)
 * @method static \Illuminate\Database\Query\Builder|\App\User wherePassword($value)
 * @method static \Illuminate\Database\Query\Builder|\App\User whereRegIp($value)
 * @method static \Illuminate\Database\Query\Builder|\App\User whereRegTime($value)
 * @method static \Illuminate\Database\Query\Builder|\App\User whereLoginIp($value)
 * @method static \Illuminate\Database\Query\Builder|\App\User whereLoginTime($value)
 * @method static \Illuminate\Database\Query\Builder|\App\User whereLoginCount($value)
 * @method static \Illuminate\Database\Query\Builder|\App\User whereRole($value)
 * @method static \Illuminate\Database\Query\Builder|\App\User whereStatus($value)
 * @method static \Illuminate\Database\Query\Builder|\App\User whereRememberToken($value)
 * @method static \Illuminate\Database\Query\Builder|\App\User whereDeletedAt($value)
 * @method static \Illuminate\Database\Query\Builder|\App\User whereCreatedAt($value)
 * @method static \Illuminate\Database\Query\Builder|\App\User whereUpdatedAt($value)
 * @mixin \Eloquent
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Goods[] $goods
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\UserAddress[] $userAddress
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Orders[] $orders
 */
class User extends Model implements AuthenticatableContract, CanResetPasswordContract {

	use Authenticatable, CanResetPassword;

	/**
	 * The database table used by the model.
	 *
	 * @var string
	 */
	protected $table = 'users';

	/**
	 * The attributes that are mass assignable.
	 *
	 * @var array
	 */
	protected $fillable = ['name', 'email', 'password'];

	/**
	 * The attributes excluded from the model's JSON form.
	 *
	 * @var array
	 */
	protected $hidden = ['password', 'remember_token'];

    public function goods(){
        return $this->hasMany('App\Goods','user_id');
    }

	public function userAddress()
	{
		return $this->hasMany('App\UserAddress','user_id');
	}

	public function orders(){
		return $this->hasMany('App\Orders','order_id');
	}

}
